

<%-- 
    Document   : oEstrategico
    Created on : 10/04/2010, 03:05:56 PM
    Author     : LAPTOP01
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="/tags/c" prefix="c"%>
<%@ include file="seguridad.jsp" %>
<script src="scripts/ajax.js" language="JavaScript"></script>

<html>
    <script LANGUAGE="JavaScript">
        var habilitar=0;
        function regresar(){

            var form = document.getElementById("PEIForm");
            var descObj = document.getElementById("descObj").value;
            var descObjEsp = document.getElementById("descObjEsp").value;
            var codObjEsp = document.getElementById("codObjEsp").value;


            //form.action="PEI.do?dispatch=listarPlanOperativo&descObj="+descObj+"&descObjEsp="+descObjEsp+"&codOE="+codObjEsp;
            //Ini agregado
            var descObjEspBack = document.getElementById("descObjEspBack").value;
            var descObjBack = document.getElementById("descObjBack").value;

            var codObjBack = document.getElementById("codObjBack").value;
            var codObjEspBack = document.getElementById("codObjEspBack").value;
            form.action="PEI.do?dispatch=listarPlanOperativo&codObjBack="+codObjBack+"&codObjEspBack="+codObjEspBack+"&codOE="+codObjEsp+"&descObjBack="+descObjBack+"&descObjEspBack="+descObjEspBack;//descObjEspBack
            //Fin agregado

            form.method="post";

            form.submit();

        }
       

        function validando(){
            var tFMe = document.getElementById("tipoFisimeta").value;
            var cant = document.getElementById("cantActPer").value;
            var inicio = Math.floor(document.getElementById("inicio").value);
            var fin = Math.floor(document.getElementById("fin").value);
            var suma=0;
            var flag=0;
            if(tFMe==-1){
                alert("Seleccionar la Meta"); 
                return;
            }
            if(tFMe==1){
                for(inicio;inicio<=fin;inicio++){
                    var num=Math.floor(document.getElementById("mes"+inicio+"FisiMeta").value);
                    suma=suma+num;
                }
                if(suma==cant){
                   
                    insertar();
                }
                else{
                    alert("La suma total debe ser "+cant);
                  
                    return;
                }
            }
            if(tFMe==2){
                for(inicio;inicio<=fin;inicio++){
                    var num=Math.floor(document.getElementById("mes"+inicio+"FisiMeta").value);
                    if(num!=cant){
                        flag=1;
                    }
                }
                if(flag==0){
                    insertar();
                }
                if(flag==1){
                    alert("La cantidad constante debe ser "+cant);
                    return;
                }
            }
            
        }


        function editarT(codMA,tFMe,mes1,mes2,mes3,mes4,mes5,mes6,mes7,mes8,mes9,mes10,mes11,mes12,cod){
            document.getElementById("opcionFisiMeta").value=2;
            document.getElementById("codMetaAper").value=codMA;
            document.getElementById("tipoFisimeta").value=tFMe;
            document.getElementById("mes1FisiMeta").value=mes1;
            document.getElementById("mes2FisiMeta").value=mes2;
            document.getElementById("mes3FisiMeta").value=mes3;
            document.getElementById("mes4FisiMeta").value=mes4;
            document.getElementById("mes5FisiMeta").value=mes5;
            document.getElementById("mes6FisiMeta").value=mes6;
            document.getElementById("mes7FisiMeta").value=mes7;
            document.getElementById("mes8FisiMeta").value=mes8;
            document.getElementById("mes9FisiMeta").value=mes9;
            document.getElementById("mes10FisiMeta").value=mes10;
            document.getElementById("mes11FisiMeta").value=mes11;
            document.getElementById("mes12FisiMeta").value=mes12;
            document.getElementById("codFisiMeta").value=cod;
              activar();
        }

        function confirmAction(){
            if (confirm("Se borrara Meta Física  \n ¿Esta seguro de continuar? "))
                return true;
            else return false;
        }

        function confirmActionGuardar(){
            if (confirm("Se Guardara los cambios hechos en la pantalla  \n ¿Esta seguro de continuar? "))
                return true;
            else
                return false;
        }


        
        function eliminar(codFM,codMA){
            if (confirmAction()==false) return;
            var idDiv = "divTabla";
            var metodo = "GET";
            var tipo=3;
            var tFMe=0;
            var mes1=0;
            var mes2=0;
            var mes3=0;
            var mes4=0;
            var mes5=0;
            var mes6=0;
            var mes7=0;
            var mes8=0;
            var mes9=0;
            var mes10=0;
            var mes11=0;
            var mes12=0;
            var url = "consultasAjax/listarMetaFisicaAjax.jsp?tFMe="+tFMe+"&mes1="+mes1+"&mes2="+mes2+
                "&mes3="+mes3+"&mes4="+mes4+"&mes5="+mes5+"&mes6="+mes6+"&mes7="+mes7+
                "&mes8="+mes8+"&mes9="+mes9+"&mes10="+mes10+"&mes11="+mes11+"&mes12="+
                mes12+"&codMA="+codMA+"&codFM="+codFM+"&tipo="+tipo;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            activar();
        }




        

        function insertar(){
            if (confirmActionGuardar()==false) {
                return;
            }
            var tipo=document.getElementById("opcionFisiMeta").value;
            var codMA = document.getElementById("codMetaAper").value;
            var codFM = document.getElementById("codFisiMeta").value;
            var tFMe = document.getElementById("tipoFisimeta").value;
            var mes1 = document.getElementById("mes1FisiMeta").value;
            var mes2 = document.getElementById("mes2FisiMeta").value;
            var mes3 = document.getElementById("mes3FisiMeta").value;
            var mes4 = document.getElementById("mes4FisiMeta").value;
            var mes5 = document.getElementById("mes5FisiMeta").value;
            var mes6 = document.getElementById("mes6FisiMeta").value;
            var mes7 = document.getElementById("mes7FisiMeta").value;
            var mes8 = document.getElementById("mes8FisiMeta").value;
            var mes9 = document.getElementById("mes9FisiMeta").value;
            var mes10 = document.getElementById("mes10FisiMeta").value;
            var mes11 = document.getElementById("mes11FisiMeta").value;
            var mes12 = document.getElementById("mes12FisiMeta").value;

            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarMetaFisicaAjax.jsp?tFMe="+tFMe+"&mes1="+mes1+"&mes2="+mes2+
                "&mes3="+mes3+"&mes4="+mes4+"&mes5="+mes5+"&mes6="+mes6+"&mes7="+mes7+
                "&mes8="+mes8+"&mes9="+mes9+"&mes10="+mes10+"&mes11="+mes11+"&mes12="+
                mes12+"&codMA="+codMA+"&codFM="+codFM+"&tipo="+tipo;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            document.getElementById("opcionFisiMeta").value=1;
            document.getElementById("tipoFisimeta").value=-1;
            document.getElementById("mes1FisiMeta").value=0;
            document.getElementById("mes2FisiMeta").value=0;
            document.getElementById("mes3FisiMeta").value=0;
            document.getElementById("mes4FisiMeta").value=0;
            document.getElementById("mes5FisiMeta").value=0;
            document.getElementById("mes6FisiMeta").value=0;
            document.getElementById("mes7FisiMeta").value=0;
            document.getElementById("mes8FisiMeta").value=0;
            document.getElementById("mes9FisiMeta").value=0;
            document.getElementById("mes10FisiMeta").value=0;
            document.getElementById("mes11FisiMeta").value=0;
            document.getElementById("mes12FisiMeta").value=0;
                  desactivar();
        }


        function listar(){

            var cant = 0;
            var tipo=0;
            var codMA = document.getElementById("codMetaAper").value;;
            var codFM = 0;
            var tFMe = 0;
            var mes1 = 0;
            var mes2 = 0;
            var mes3 = 0;
            var mes4 = 0;
            var mes5 = 0;
            var mes6 = 0;
            var mes7 = 0;
            var mes8 = 0;
            var mes9 = 0;
            var mes10 = 0;
            var mes11 = 0;
            var mes12 = 0;
            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarMetaFisicaAjax.jsp?tFMe="+tFMe+"&mes1="+mes1+"&mes2="+mes2+
                "&mes3="+mes3+"&mes4="+mes4+"&mes5="+mes5+"&mes6="+mes6+"&mes7="+mes7+
                "&mes8="+mes8+"&mes9="+mes9+"&mes10="+mes10+"&mes11="+mes11+"&mes12="+
                mes12+"&codMA="+codMA+"&codFM="+codFM+"&tipo="+tipo+"&cant="+cant;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            document.getElementById("opcionFisiMeta").value=1;

        }
        function autoCompletarDiv(metodo,url,cadena,async,idDiv)
        {
            if( window.XMLHttpRequest )
                ajax = new XMLHttpRequest(); 
            else
                ajax = new ActiveXObject("Microsoft.XMLHTTP");
            ELEMENT_DIV = idDiv;
            ajax.onreadystatechange = funcionCallbackVerDiv;
            ajax.open( metodo, url, async);
            ajax.send(cadena);
        }

        function funcionCallbackVerDiv()
        {
            if( ajax.readyState == 4 )
            {
                if( ajax.status == 200 )
                { //alert(ajax.responseText); 
                    document.getElementById(ELEMENT_DIV).innerHTML = ajax.responseText;
                }
            }
        }

        
        function eventoSoloNumeros(){


            var key = event.keyCode;

            if ((key == 13 )|| (key >= 48 && key <= 57) || (key==8 )==true)
                event.returnValue = true;
            else
                event.returnValue = false;

        }


        function validar(){
            var inicio = Math.floor(document.getElementById("inicio").value);
            var fin = Math.floor(document.getElementById("fin").value);
            for(inicio;inicio<=fin;inicio++){
                document.getElementById("mes"+inicio+"FisiMeta").disabled = false;
            }
            listar();

            var flag = Math.floor(document.getElementById("flag").value);
            if(flag==0){
                activar();
            }
            if(flag==1){
                desactivar();
            }
        }


        function desactivar(){
           
                PEIForm.grabar.disabled = true;

          
             
        }


        
        function activar(){
           
            PEIForm.grabar.disabled = false;
        }




    </script>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link type="text/css" rel="stylesheet" href="lib/css/Style_Font_Text.css" >
        <link type="text/css" rel="stylesheet" href="lib/css/Style_PageTable.css" >
        <link type="text/css" rel="stylesheet" href="lib/css/Style_Index.css" >
        <title>JSP Page</title>
    </head>

    <body onload="validar()">
        <center>
            <h1 class="substylo">Ingreso de Meta F&iacute;sica</h1>
        </center>
        <div style="overflow: auto; width:710px; height: 400px">
            <html:form action="PEI.do?dispatch=ingresarMetaFisica" styleId="PEIForm">
                <html:hidden property="opcionFisiMeta" styleId="opcionFisiMeta" value="1"/>
                <html:hidden property="codActPer" styleId="fkTAct"/>
                <html:hidden property="inicio" styleId="inicio" />
                <html:hidden property="fin" styleId="fin" />
                <html:hidden property="flag" styleId="flag" />
                <html:hidden property="codObjEsp" styleId="codObjEsp" />
                <html:hidden property="codObj" styleId="codObj" />

                <!--Ini agregado-->
                <html:hidden property="codObjEspBack" styleId="codObjEspBack" />
                <html:hidden property="codObjBack" styleId="codObjBack" />
                 <html:hidden property="descObjBack" styleId="descObjBack"/>
                 <html:hidden property="descObjEspBack" styleId="descObjEspBack"/>
                <!--Fin agregado-->


                <table border="0" align="center" cellspacing="0" style="width: 600px">
                    <tr>
                        <td style="width: 150px">Objetivo General Estrat&eacute;gico</td>
                        <td style="width: 400px">
                            <html:textarea  styleId="descObj" property="descObj"  disabled="true" rows="5" cols="50" styleClass="textarea"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 150px">Objetivo Espec&iacute;fico Estrat&eacute;gico</td>
                        <td style="width: 400px">
                            <html:textarea  styleId="descObjEsp" property="descObjEsp"  disabled="true" rows="5" cols="50" styleClass="textarea"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 150px">Actividad Estrat&eacute;gica</td>
                        <td style="width: 400px">
                            <html:textarea  styleId="descActPer" property="descActPer"  disabled="true" rows="5" cols="50" styleClass="textarea"/>
                        </td>
                    </tr>

                                    <tr>
                                          <td style="width: 150px">
                                            Descripci&oacute;n de Meta F&iacute;sica
</td>
                        <td style="width: 400px">
                            <html:textarea property="umActPer" disabled="true"  styleId="umActPer" rows="4" cols="20"/> Cantidad<html:text property="cantActPer" disabled="true" readonly="true" styleId="cantActPer" size="7"/> UM<html:text property="tipoActPer" disabled="true" styleId="tipoActPer" maxlength="2" size="2"/></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 150px">Tipo de medici&oacute;n de meta f&iacute;sica anual</td>
                                        <td style="width: 400px"><html:select  styleId="tipoFisimeta" property="tipoFisimeta"  >
                                            <html:option value="-1">[--Seleccionar--]</html:option>
                                            <html:option value="1">Acumulado</html:option>
                                            <html:option value="2">Permanente</html:option>
                                			</html:select>
                                		</td>
                                    </tr>

                </table>
                <br>
                <table border="0" align="center" cellspacing="0" style="width: 700px">
                    <tr>
                        <td>Enero:</td>
                        <td><html:text  styleId="mes1FisiMeta" property="mes1FisiMeta" maxlength="400" onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                        <td>Febrero:</td>
                        <td><html:text  styleId="mes2FisiMeta" property="mes2FisiMeta" maxlength="400" onkeypress="eventoSoloNumeros()"  disabled="true" styleClass="textN"/></td>
                        <td>Marzo:</td>
                        <td><html:text  styleId="mes3FisiMeta" property="mes3FisiMeta" maxlength="400"  onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                        <td>Abril:</td>
                        <td><html:text  styleId="mes4FisiMeta" property="mes4FisiMeta" maxlength="400"  onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                    </tr>
                    <tr>
                        <td>Mayo:</td>
                        <td><html:text  styleId="mes5FisiMeta" property="mes5FisiMeta" maxlength="400" onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                        <td>Junio:</td>
                        <td><html:text  styleId="mes6FisiMeta" property="mes6FisiMeta" maxlength="400" onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                        <td>Julio:</td>
                        <td><html:text  styleId="mes7FisiMeta" property="mes7FisiMeta" maxlength="400" onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                        <td>Agosto:</td>
                        <td><html:text  styleId="mes8FisiMeta" property="mes8FisiMeta" maxlength="400" onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                    </tr>
                    <tr>
                        <td>Setiembre:</td>
                        <td><html:text  styleId="mes9FisiMeta" property="mes9FisiMeta" maxlength="400" onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                        <td>Octubre:</td>
                        <td><html:text  styleId="mes10FisiMeta" property="mes10FisiMeta" maxlength="400" onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                        <td>Noviembre:</td>
                        <td><html:text  styleId="mes11FisiMeta" property="mes11FisiMeta" maxlength="400" onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                        <td>Diciembre:</td>
                        <td><html:text  styleId="mes12FisiMeta" property="mes12FisiMeta" maxlength="400" onkeypress="eventoSoloNumeros()" disabled="true" styleClass="textN"/></td>
                    </tr>
                    <tr>
                        <td colspan="3">
                            <label style="color: blue"> Solo se permite grabar un registro en este M&oacute;dulo</label>
                        </td>
                    </tr>
                    <html:hidden property="codFisiMeta" styleId="codFisiMeta"/>
                    <html:hidden property="codMetaAper" styleId="codMetaAper"/>

                </table>

                <input type='button' id='grabar' value='Grabar' onclick='validando();' class='submit2'  />
                <html:button property="button"  value="regresar" onclick="regresar()" styleClass="submit2" />

                <br>



                <div id="divTabla" style="width: 99%"/>
                




            </html:form>
        </div>
    </body>
